#include <head.h>
// 消费者
int main(int argc, char *argv[])
{
    int fd = open(argv[1], O_RDWR);
    OPEN_ERR(fd);
    char buf[1024];
    flock(fd, LOCK_EX);

    lseek(fd, 0, SEEK_SET);
    read(fd, buf, sizeof(buf));

    printf("消费者消费了：%s\n", buf);
    memset(buf, 0, sizeof(buf));
    lseek(fd, 0, SEEK_SET);
    write(fd, buf, sizeof(buf));
    printf("消费者消费完毕\n");

    flock(fd, LOCK_UN);
    close(fd);
    return 0;
}